package com.bootdo.program.wallpaper.service;

import com.bootdo.common.utils.seq.GenerateSequenceUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

import com.bootdo.program.wallpaper.dao.WalletDetailsDao;
import com.bootdo.program.wallpaper.domain.WalletDetailsDO;
import com.bootdo.program.wallpaper.service.WalletDetailsService;



@Service
public class WalletDetailsService   {
	@Autowired
	private WalletDetailsDao walletDetailsDao;
	

	public WalletDetailsDO get(Long id){
		return walletDetailsDao.get(id);
	}
	

	public List<WalletDetailsDO> list(Map<String, Object> map){
		return walletDetailsDao.list(map);
	}
	

	public int count(Map<String, Object> map){
		return walletDetailsDao.count(map);
	}
	

	public int save(WalletDetailsDO walletDetails){
		return walletDetailsDao.save(walletDetails);
	}
	

	public int update(WalletDetailsDO walletDetails){
		return walletDetailsDao.update(walletDetails);
	}
	

	public int remove(Long id){
		return walletDetailsDao.remove(id);
	}
	

	public int batchRemove(Long[] ids){
		return walletDetailsDao.batchRemove(ids);
	}


	/**
	 * 新增钱包记录
	 * @param userId 用户id
	 * @param money 金额
	 * @param platform 平台
	 * @param dataType 数据类型 1收入 2支出
	 * @return
	 */
	public int addWallet(String userId, BigDecimal money, int platform, int dataType){
		//新增钱包记录
		WalletDetailsDO walletDetailsDO = new WalletDetailsDO();
		walletDetailsDO.setUserId(userId);
		walletDetailsDO.setMoney(money);
		walletDetailsDO.setCreateTime(new Date());
		walletDetailsDO.setPlatform(platform);
		walletDetailsDO.setDataType(dataType);
		walletDetailsDO.setFlowNo(GenerateSequenceUtil.generateSequenceNo());
		return walletDetailsDao.save(walletDetailsDO);
	}
}
